//
//  OSUnfairLockDemo.swift
//  sinaDemo
//
//  Created by admin on 2021/7/9.
//

import UIKit

class OSUnfairLockDemo: LockBase {
    //这个锁是替代自旋锁的锁，内部也是会休眠的。
    var lock:os_unfair_lock = os_unfair_lock.init()
    var lock1:os_unfair_lock = os_unfair_lock.init()
    
    override func saleTickets() {
        os_unfair_lock_lock(&lock)
        super.saleTickets()
        os_unfair_lock_unlock(&lock)
    }
    override func saveMoney() {
        os_unfair_lock_lock(&lock1)
        super.saveMoney()
        os_unfair_lock_unlock(&lock1)
    }
    override func payMoney() {
        os_unfair_lock_lock(&lock1)
        super.payMoney()
        os_unfair_lock_unlock(&lock1)
    }
   
}
